## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.5 ✓ dplyr 1.0.7
=======
rm(list=ls())
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5 ✓ purrr 0.3.4
## ✓ tibble 3.1.2 ✓ dplyr 1.0.7
>>>>>>> b0db76007b39124248792c541400c66511261655
## ✓ tidyr 1.1.4 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
<<<<<<< HEAD
=======
setwd("~/Documents/GitHub/Assignment-1")
pge_data <- read_csv("https://pge-energydatarequest.com/public_datasets")
>>>>>>> b0db76007b39124248792c541400c66511261655
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## `<noscript><meta http-equiv='refresh' content='0;url=https://pge-energydatarequest.com/nojswarn'></noscript><!DOCTYPE html>` = col_character()
## )
## Warning: 1279 parsing failures.
## row col expected actual file
## 104 -- delimiter or quote : 'https://pge-energydatarequest.com/public_datasets'
## 104 -- delimiter or quote a 'https://pge-energydatarequest.com/public_datasets'
## 104 -- delimiter or quote : 'https://pge-energydatarequest.com/public_datasets'
## 104 -- delimiter or quote t 'https://pge-energydatarequest.com/public_datasets'
## 104 -- delimiter or quote : 'https://pge-energydatarequest.com/public_datasets'
## ... ... .................. ...... ...................................................
## See problems(...) for more details.
<<<<<<< HEAD
=======
pge_20_q1_elec <- read_csv("PGE_2020_Q1_ElectricUsageByZip.csv")
>>>>>>> b0db76007b39124248792c541400c66511261655
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
<<<<<<< HEAD
=======
library(tidyverse)
years <- 2017:2020
quarters <- 1:4
type <- "Electric"
pge_1720_elec <- NULL
for(year in years) {
for(quarter in quarters) {
filename <-
paste0(
"PGE_",
year,
"_Q",
quarter,
"_",
type,
"UsageByZip.csv"
)
print(filename)
temp <- read_csv(filename)
pge_1720_elec <- rbind(pge_1720_elec,temp)
#
saveRDS(pge_1720_elec, "pge_1720_elec.rds")
}
}
>>>>>>> b0db76007b39124248792c541400c66511261655
## [1] "PGE_2017_Q1_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2017_Q2_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2017_Q3_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2017_Q4_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2018_Q1_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2018_Q2_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2018_Q3_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2018_Q4_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2019_Q1_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2019_Q2_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2019_Q3_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2019_Q4_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2020_Q1_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2020_Q2_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2020_Q3_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2020_Q4_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
<<<<<<< HEAD
## [1] "numeric"
=======
class(pge_1720_elec$TOTALKWH)
## [1] "numeric"
# adding 2021 Q1 and Q2
year <- 2021
quarters <- 1:2
type <- "Electric"
pge_21_electric <- NULL
for(quarter in quarters) {
filename <-
paste0(
"PGE_",
year,
"_Q",
quarter,
"_",
type,
"UsageByZip.csv"
)
print(filename)
temp <- read_csv(filename)
pge_21_electric <- rbind(pge_21_electric,temp)
#
saveRDS(pge_21_electric, "pge_21_electric.rds")
}
>>>>>>> b0db76007b39124248792c541400c66511261655
## [1] "PGE_2021_Q1_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
## [1] "PGE_2021_Q2_ElectricUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALKWH = col_number(),
## AVERAGEKWH = col_number()
## )
<<<<<<< HEAD
## [1] "numeric"
## [1] "numeric"
## [1] "numeric"
=======
class(pge_21_electric$TOTALKWH)
## [1] "numeric"
class(pge_1720_elec$TOTALKWH)
## [1] "numeric"
pge_elec_total <- rbind(pge_1720_elec, pge_21_electric)
class(pge_elec_total$TOTALKWH)
## [1] "numeric"
library(tidyverse)
years <- 2017:2020
quarters <- 1:4
type <- "Gas"
pge_1720_gas <- NULL
for(year in years) {
for(quarter in quarters) {
filename <-
paste0(
"PGE_",
year,
"_Q",
quarter,
"_",
type,
"UsageByZip.csv"
)
print(filename)
temp <- read_csv(filename)
pge_1720_gas <- rbind(pge_1720_gas,temp)
#
saveRDS(pge_1720_gas, "pge_1720_gas.rds")
}
}
>>>>>>> b0db76007b39124248792c541400c66511261655
## [1] "PGE_2017_Q1_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2017_Q2_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2017_Q3_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_double()
## )
## [1] "PGE_2017_Q4_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2018_Q1_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2018_Q2_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2018_Q3_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_double()
## )
## [1] "PGE_2018_Q4_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2019_Q1_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2019_Q2_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2019_Q3_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2019_Q4_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2020_Q1_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2020_Q2_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2020_Q3_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_double()
## )
## [1] "PGE_2020_Q4_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
<<<<<<< HEAD
=======
# adding 2021 Q1 and Q2
year <- 2021
quarters <- 1:2
type <- "Gas"
pge_21_gas <- NULL
for(quarter in quarters) {
filename <-
paste0(
"PGE_",
year,
"_Q",
quarter,
"_",
type,
"UsageByZip.csv"
)
print(filename)
temp <- read_csv(filename)
pge_21_gas <- rbind(pge_21_gas,temp)
#
saveRDS(pge_21_gas, "pge_21_gas.rds")
}
>>>>>>> b0db76007b39124248792c541400c66511261655
## [1] "PGE_2021_Q1_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
## [1] "PGE_2021_Q2_GasUsageByZip.csv"
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## ZIPCODE = col_double(),
## MONTH = col_double(),
## YEAR = col_double(),
## CUSTOMERCLASS = col_character(),
## COMBINED = col_character(),
## TOTALCUSTOMERS = col_number(),
## TOTALTHM = col_number(),
## AVERAGETHM = col_number()
## )
<<<<<<< HEAD
## [1] "numeric"
=======
pge_gas_total <- rbind(pge_1720_gas, pge_21_gas)
class(pge_gas_total$TOTALTHM)
## [1] "numeric"
#Conversions
library(tidyverse)
#KWH to KBTU
pge_elec_total$TOTALKBTU <- pge_elec_total$TOTALKWH * 3.412
#Therms to KBTUs
pge_gas_total$TOTALKBTU <- pge_gas_total$TOTALTHM * 99976.1
#Plots
library(tidyverse)
library(plotly)
>>>>>>> b0db76007b39124248792c541400c66511261655
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
<<<<<<< HEAD
## [1] "Elec- Agricultural" "Elec- Commercial" "Elec- Industrial"
## [4] "Elec- Residential"